//package com.acxy.weixin.api;
//
//import com.acxy.ants.common.kit.HttpKit;
//import com.acxy.ants.common.kit.StrEncryptKit;
//import com.acxy.ants.common.kit.StrKit;
//
//import java.util.Map;
//import java.util.Set;
//import java.util.TreeMap;
//
///**
// * @author MrShun
// * @version 1.0
// * @Date 2017-06-22
// */
//public class PayApi extends WeiXinParams{
//
//    //统一订单接口
//    private final static String unified_order_api = "https://api.mch.weixin.qq.com/pay/unifiedorder";
//
//    public static Map getUnifiedOrderParams(){
////        //获取统一订单信息
////        String Id = StrKit.randomUUID();
////        BigDecimal total_money = (weiXinPay.money).multiply(new BigDecimal(100));
////        BigInteger total_fee = (total_money).setScale(0, BigDecimal.ROUND_HALF_UP).toBigInteger();
////
////        TreeMap payMap = new TreeMap();
////        payMap.put("appid", weiXinPay.appId);
////        payMap.put("mch_id", weiXinPay.mchId);
////        payMap.put("nonce_str", StringUtil.get32UUID());
////        payMap.put("notify_url", weiXinPay.notifyURL);
////        payMap.put("body", weiXinPay.body);
////        payMap.put("openid", information.getOpenid());
////        payMap.put("out_trade_no", Id);
////        payMap.put("spbill_create_ip", information.getIp());
////        payMap.put("total_fee", total_fee);
////        payMap.put("trade_type", "JSAPI");
//
//        String result = HttpKit.sendPost(unified_order_api, "");
//        ApiResult data = new ApiResult(result);
//
//        String timeStamp = Long.toString(System.currentTimeMillis() / 1000);
//        String nonceStr = StrKit.randomUUID();
//
//        TreeMap<String, Object> map = new TreeMap<String, Object>();
//        map.put("appId", appId);
//        map.put("nonceStr", nonceStr);
//        map.put("package", "prepay_id="+String.valueOf(data.get("prepay_id")));
//        map.put("signType", "MD5");
//        map.put("timeStamp", timeStamp);
//
//        data.put("paySign", md5Sign(map, payKey));
//        data.put("timeStamp", timeStamp);
//        data.put("nonceStr", nonceStr);
//        return data.toMap();
//    }
//
//    /**
//     * 采用TreeMap 按首字母排序 统一小写字母 生成MD5签名
//     * @param map 对象数据
//     * @param payKey 支付秘钥
//     * @return
//     */
//    private static String md5Sign(TreeMap<String, Object> map, String payKey){
//        StringBuffer sb = new StringBuffer();
//        Set<Map.Entry<String, Object>> entries = map.entrySet();
//
//        for (Map.Entry<String, Object> entry : entries) {
//            String key = entry.getKey();
//            Object value = entry.getValue();
//            sb.append(key+"="+value+"&");
//        }
//        String stringSignTemp = String.valueOf(sb);
//        stringSignTemp = stringSignTemp.substring(0, stringSignTemp.length()-1);
//        if(payKey!=null) stringSignTemp = stringSignTemp+"&key="+ payKey;
//        String md5Sign = StrEncryptKit.MD5(stringSignTemp).toUpperCase();
//        return md5Sign;
//    }
//}
